package br.net.woodstock.tickettoride.client.web;

import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.http.HttpServletRequest;

import br.net.woodstock.tickettoride.client.beans.MapTicketConverter;

public class RequestAttributeTargetHandler implements TargetHandler {

	private static final MapTicketConverter	CONVERTER	= new MapTicketConverter();

	@Override
	public HttpServletRequest handle(final HttpServletRequest request, final byte[] bytes) {
		Map<String, String> data = RequestAttributeTargetHandler.CONVERTER.fromBytes(bytes);
		for (Entry<String, String> entry : data.entrySet()) {
			request.setAttribute(entry.getKey(), entry.getValue());
		}
		return request;
	}

}
